#ifndef ALLH_H_
#define ALLH_H_

#define HEAD_ON P1OUT |= BIT0;
#define SHOULDER_ON P1OUT |= BIT1;
#define LEGS_ON P1OUT |= BIT2;
#define CHEST_ON P1OUT |= BIT3;

#define HEAD_OFF P1OUT &= ~BIT0;
#define SHOULDER_OFF P1OUT &= ~BIT1;
#define LEGS_OFF P1OUT &= ~BIT2;
#define CHEST_OFF P1OUT &= ~BIT3;

void delay_ms(unsigned int count)
{
	unsigned int i,j;
	for(i=0;i<count;i++)
	{ 
	for(j=0;j<100;j++)
	{   _delay_cycles(1600-1);
	}
	}	
}
void delay(unsigned int count)
{
	unsigned int i,j;
	for(i=0;i<count;i++)
	{ 
	//for(j=0;j<100;j++)
	{   _delay_cycles(1600);
	}
	}	
}

void All_ON()
{
	HEAD_ON;
	SHOULDER_ON;
	LEGS_ON;
	CHEST_ON;
}

void All_OFF()
{
	HEAD_OFF;
	SHOULDER_OFF;
	LEGS_OFF;
	CHEST_OFF;
}
void All_SLOWOFF1()
{	unsigned int i,j;
	for(i=0;i<50;i++)
	{
	for(j=0;j<2;j++)
	{
	All_ON();
	delay(50-i);	
	 All_OFF();
	 delay(i);
	}
	}
}

void All_SLOWOFF2()
{	unsigned int i,j;
	for(i=0;i<50;i++)
	{
	for(j=0;j<4;j++)
	{
	All_ON();
	delay(50-i);	
	 All_OFF();
	 delay(i);
	}
	}
}

void All_SLOWOFF6()
{	unsigned int i,j;
	for(i=100;i>0;i++)
	{
	for(j=0;j<2;j++)
	{
	All_ON();
	delay(100-i);
	 All_OFF();
	 delay(i);
	}
	}
		
	
	for(i=100;i>0;i++)
	{
	for(j=0;j<2;j++)
	{
	All_ON();
	delay(i);
	 All_OFF();
	 delay(i-100);
	}
	}
}
void All_SLOWOFF()
{	unsigned int i,j;
	for(i=0;i<100;i++)
	{
	for(j=0;j<3;j++)
	{
	All_ON();
	delay(100-i);	
	 All_OFF();
	 delay(i);
	}
	}
}

void All_SLOWONOFF()
{	unsigned int i;
	for(i=50;i>0;i++)
	{
	All_ON();
	delay(50-i);
	 All_OFF();
	 delay(i);
	}
	
	for(i=0;i<50;i++)
	{	
	All_ON();
	delay(50-i);
	 All_OFF();
	 delay(i);	
	}
}

void BLINK()
{	unsigned int i,j;
	for(i=0;i<50;i++)
	{
	All_ON();
	delay(500);	
	 All_OFF();
	 delay(500);	
	}

}

void BLINK1()
{	unsigned int i,j;
	for(i=0;i<40;i++)
	{
	All_ON();
	delay(500);	
	 All_OFF();
	 delay(500);	
	}

}
void BLINK7()
{	unsigned int i,j;
	for(i=0;i<70;i++)
	{
	All_ON();
	delay(500);	
	 All_OFF();
	 delay(500);	
	}

}

void NOBLINK()
{	unsigned int i,j;
	for(i=0;i<40;i++)
	{
	All_ON();
	delay(500);	
	// All_OFF();
	 delay(500);	
	}

}
#endif /*ALLH_H_*/
